#include "kzfqgraphicslineitem.h"
#include <QDebug>

kzfQGraphicsLineItem::kzfQGraphicsLineItem(QGraphicsLineItem *parent)
    : QGraphicsLineItem{parent}
{
    setFlags(ItemIsSelectable);
}

kzfQGraphicsLineItem::kzfQGraphicsLineItem(const QLineF &line, QGraphicsItem *parent)
    : QGraphicsLineItem{line, parent}
{
    setFlags(ItemIsSelectable);
}

kzfQGraphicsLineItem::kzfQGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent)
    : QGraphicsLineItem{x1, y1, x2, y2, parent}
{
    setFlags(ItemIsSelectable);
}


//-------------------------------------------------------------------------------
void kzfQGraphicsLineItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{


    // if (event->button() == Qt::LeftButton) {
    //     qDebug("item mouse press");
    //     setSelected(true);//点击选中,再点击取消
    //     qDebug()<<"line chect one"<<isSelected();
    // }



    QGraphicsItem::mousePressEvent(event);
    update();
}

void kzfQGraphicsLineItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    QGraphicsItem::mouseMoveEvent(event);

    // qDebug("item mouse move");
    // if (event->modifiers() & Qt::ShiftModifier) {
    //     // stuff << event->pos();
    //     qDebug()<<event->pos();
    //     update();
    //     return;
    // }

    update();
}

void kzfQGraphicsLineItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    QGraphicsItem::mouseReleaseEvent(event);

    // setActive(false);
    // qDebug("item mouse release");

    update();
}
